package com.augurit.agmobile.agwater5.drainage.supervise.view

import android.app.Activity
import android.os.Bundle
import com.augurit.agmobile.agwater5.drainage.common.adapter.SimpleFragmentStatePagerAdapter
import com.augurit.agmobile.agwater5.drainage.common.constant.StringConstant
import com.augurit.agmobile.agwater5.drainage.common.ex.launchActivity
import com.augurit.agmobile.agwater5.drainage.supervise.model.SuperviseType
import com.augurit.agmobile.agwater5.drainage.supervise.model.SuperviseVariousTab
import com.example.arm.base.BaseActivity
import com.example.drainage.databinding.ActivitySuperviseVariousBinding

/**
 * @author 创建人 ：yanghaozhang
 * @version 1.0
 * @package 包名 ：com.augurit.agmobile.agwater5.drainage.supervise.view
 * @createTime 创建时间 ：2022/1/4
 * @modifyBy 修改人 ：
 * @modifyTime 修改时间 ：
 * @modifyMemo 修改备注：
 */
class SuperviseVariousActivity : BaseActivity<ActivitySuperviseVariousBinding>() {

    private var facilityType: SuperviseType = SuperviseType.Reservoir

    private var id: String? = null

    companion object {
        fun jump(activity: Activity, facilityType: SuperviseType, id: String) {
            activity.launchActivity<SuperviseVariousActivity> {
                putExtra(StringConstant.KEY_TYPE, facilityType)
                putExtra(StringConstant.KEY_ID, id)
            }
        }
    }

    override fun initView(savedInstanceState: Bundle?): ActivitySuperviseVariousBinding {
        return ActivitySuperviseVariousBinding.inflate(layoutInflater)
    }

    override fun initData(savedInstanceState: Bundle?) {
        initIntent()
        initView()
        initViewModel()
        initData()
    }

    //-----------------已定义方法---------------------------
    private fun initIntent() {
        if (intent.hasExtra(StringConstant.KEY_TYPE)) {
            facilityType = intent.getSerializableExtra(StringConstant.KEY_TYPE) as SuperviseType
        }
        if (intent.hasExtra(StringConstant.KEY_ID)) {
            id = intent.getStringExtra(StringConstant.KEY_ID)
        }
    }

    private fun initView() {
//        immersionStatusBar()
//        mBinding.apply {
//            titlebar.setTitle(facilityType.typeName)
//                .setTitleTextColor("#222222".toColor())
//                .setTitleTextSize(18f)
//                .setLeftImageIcon(R.mipmap.back_arrow, 14)
//                .setLeftImageTint("#222222".toColor())
//                .setLeftImageClick { finish() }
//                .setImmersion(true)
//                .setBackgroundResource(R.color.white)
//
//        }
        binding.apply {
            val fragmentList = listOf(
                SuperviseVariousFragment.getInstance(facilityType, id!!, SuperviseVariousTab.SafeManager),
                SuperviseVariousFragment.getInstance(
                    facilityType, id!!, SuperviseVariousTab.EngineeringDefect
                )
            )
            viewPager.offscreenPageLimit = fragmentList.size
            viewPager.adapter = SimpleFragmentStatePagerAdapter(
                supportFragmentManager, fragmentList, listOf(
                    "安全运行管理", "工程缺陷"
                )
            )
            tabLayout.setupWithViewPager(viewPager)
        }
    }

    private fun initViewModel() {

    }

    private fun initData() {

    }

}